package cn.iocoder.yudao.module.book.dal.mysql.book;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.book.dal.dataobject.book.BookDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.book.controller.admin.book.vo.*;

/**
 * 图书 Mapper
 *
 *
 */
@Mapper
public interface BookMapper extends BaseMapperX<BookDO> {

    default PageResult<BookDO> selectPage(BookPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BookDO>()
                .eqIfPresent(BookDO::getIsbn, reqVO.getIsbn())
                .eqIfPresent(BookDO::getTitle, reqVO.getTitle())
                .eqIfPresent(BookDO::getPublisherId, reqVO.getPublisherId())
                .eqIfPresent(BookDO::getCategoryId, reqVO.getCategoryId())
                .eqIfPresent(BookDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(BookDO::getPublishDate, reqVO.getPublishDate())
                .eqIfPresent(BookDO::getLanguage, reqVO.getLanguage())
                .eqIfPresent(BookDO::getPages, reqVO.getPages())
                .betweenIfPresent(BookDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BookDO::getId));
    }

}